package org.aphelie.chronicle.ui.forms;

import org.aphelie.chronicle.ui.editors.ArcFormPage;
import org.aphelie.chronicle.ui.layout.ArcFormLayoutFactory;
import org.aphelie.chronicle.ui.parts.IFormEntry;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;

public class ReferenceSection extends ArcFormSection {

	public ReferenceSection(ArcFormPage page, Composite parent, int style) {
		super(page, parent, Section.DESCRIPTION);
		createClient(getSection(), page.getEditor().getToolkit());
	}
	
	protected void createClient(Section section, FormToolkit toolkit) {
		section.setText("References");
		section.setLayout(ArcFormLayoutFactory.createClearTableWrapLayout(false, 1));
		TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
		section.setLayoutData(data);
		
		section.setDescription("reference description");
		Composite client = toolkit.createComposite(section);
		client.setLayout(ArcFormLayoutFactory.createSectionClientTableWrapLayout(false, 3));
		section.setClient(client);
		createArchetypeEntry(client, toolkit);
	}
	
	private org.aphelie.chronicle.ui.forms.FormEntry archetypeEntry;
	protected void createArchetypeEntry(Composite client, FormToolkit toolkit) {
		archetypeEntry = new FormEntry(client, toolkit, "Archetype", "Browse", true);
		archetypeEntry.setFormEntryListener(new FormEntryAdapter(this) {
			
			
			@Override
			public void browseButtonSelected(IFormEntry entry) {
				//doOpenSelectionDialog(entry.getValue());
			}
			
		});
		
	}
	
}
